<%@ page language="java"  pageEncoding="utf-8"%>
<%@taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><s:if test="member.id != null && member.id != ''">编辑用户</s:if><s:if test="member.id == null || member.id == ''">添加用户</s:if></title>
<%@include file="../common/jscss.jsp" %>
</head>

<body>
	<!-- head -->
	<%@include file="../common/header.jsp" %>
    <!-- head--end -->
    <div class="content">
    	<div class="body_wrap clearfix">
            <div class="com_left">
            	<div class="com_pd_s1">
                	<div class="box_s2">
                    	<div class="title"><img src="images/other/icon_10.jpg" /><span><s:if test="member.id != null && member.id != ''">编辑用户</s:if><s:if test="member.id == null || member.id == ''">添加用户</s:if></span></div>
                        <div class="content">
                        	<table class="form_info">
                            	<tr>
                                	<td width="87" class="col1">学校代码：</td>
                                    <td><input type="text" id="schoolcode" name="member.schoolCode" class="def_txt_s1" value="<s:property value="member.schoolCode"/>"/></td>
                                </tr>
                                <tr>
                                	<td width="87" class="col1">用户名：</td>
                                    <td><input type="text" id="username" name="member.username" class="def_txt_s1" value="<s:property value="member.username"/>"/></td>
                                </tr>
                                <tr>
                                	<td width="87" class="col1">密码：</td>
                                    <td><input type="text" id="password" name="member.password" class="def_txt_s1" value=""/></td>
                                </tr>
                                 <tr>
                                	<td width="87" class="col1">角色：</td>
                                    <td>
                                    	<select id="roleid" name="member.roleId">
                                    		<s:iterator value="roleList" id="role">
                                    			<option <s:if test="id == member.roleId">SELECTED</s:if> value="<s:property value="id" />"><s:property value="name" /></option>
                                    		</s:iterator>
                                    	</select>
                                    </td>
                                </tr>
                                <tr>
                                	<td width="87" class="col1">手机号：</td>
                                    <td><input type="text" id="mobile" name="member.mobile" class="def_txt_s1" value="<s:property value="member.mobile"/>"/></td>
                                </tr>
                               <tr>
                                	<td width="87" class="col1"></td>
                                    <td> 
                                    <div class="operate">
                                        	<input type="button" onclick="saveMember();" value="保存" class="def_btn_s1" />
                                        	
                                        </div></td>
                                </tr>
                            </table>
                            
                        </div>
                    </div>
                    
                </div>
            </div>
            
            <!-- right -->
            <%@include file="right.jsp" %>
            <!--right--end-->
            <br class="clear" />
        </div>
    </div>
	
    <!-- body -->
    <script type="text/javascript">
    
		
    	function saveMember(){
    		var schoolCode = $("#schoolcode").val();
    		var username = $("#username").val();
    		var password = $("#password").val();
    		var roleid = $("#roleid").val();
    		var mobile = $("#mobile").val();
    		if(schoolCode == null || schoolCode == ""){
    			alert("学校代码不能为空！");
    			return false;
    		}
    		if(username == null || username == ""){
    			alert("用户昵称不能为空！");
    			return false;
    		}
    		if(roleid == null || roleid == ""){
    			alert("角色不能为空！");
    			return false;
    		}
    		if(mobile == null || mobile == ""){
    			alert("手机不能为空！");
    			return false;
    		}
    		
    		$.post("member!save.do",{
    			'member.id':'<s:property value="member.id" />',
    			'member.schoolCode':schoolCode,
    			'member.username':username,
    			'member.password':password,
    			'member.roleId':roleid,
    			'member.mobile':mobile
    		},function(data){
    			if(data!=null){
    				var ret = $.parseJSON(data);
    				if(ret.success == 'true'){
    					window.location.href="member!list.do";
    				}else{
    					alert(ret.msg);
    				}
    			}
    		});
    	}
    	
    	
    	
    </script>
</body>
</html>
